package lc.oa.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;

import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

import lc.oa.R;
import lc.oa.ui.adapter.ToDoAdapter;
import lc.oa.data.model.ToDoModel;

public class ToDoList extends ConstraintLayout {

    private RecyclerView recyclerView;
    private RecyclerView.LayoutManager layoutManager;
    private RecyclerView.Adapter adapters;
    public ToDoList(Context context) {
        super(context);
    }

    public ToDoList(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.todo_list, this);
        layoutManager=new LinearLayoutManager(context);
        if (this.getId()==R.id.to_do_list) {
            List<ToDoModel> data = new ArrayList<ToDoModel>();
            ToDoModel toDoModel = new ToDoModel();
            toDoModel.setTitle("史鹏程请假申请");
            toDoModel.setDesction("2020-07-19");
            data.add(toDoModel);
            ToDoModel toDoModel2 = new ToDoModel();
            toDoModel2.setTitle("外出申请");
            toDoModel2.setDesction("【史鹏程外出申请】");
            data.add(toDoModel2);
            ToDoModel toDoModel3 = new ToDoModel();
            toDoModel3.setTitle("报销申请");
            toDoModel3.setDesction("【史鹏程报销申请】");
            data.add(toDoModel3);
            adapters = new ToDoAdapter(data);
            recyclerView = findViewById(R.id.recyclerview);
            recyclerView.setHasFixedSize(true);
            recyclerView.setLayoutManager(layoutManager);
            recyclerView.setAdapter(adapters);
        }
        if (this.getId()==R.id.message_list) {
            List<ToDoModel> data = new ArrayList<ToDoModel>();
            ToDoModel toDoModel2 = new ToDoModel();
            toDoModel2.setTitle("公告");
            toDoModel2.setDesction("【XXX会议于2020年12月12日举行】");
            data.add(toDoModel2);
            ToDoModel toDoModel = new ToDoModel();
            toDoModel.setTitle("请假审批通知");
            toDoModel.setDesction("【您的请假申请已审批】");
            data.add(toDoModel);

            ToDoModel toDoModel3 = new ToDoModel();
            toDoModel3.setTitle("报销申请");
            toDoModel3.setDesction("【史鹏程撤回了报销申请】");
            data.add(toDoModel3);
            adapters = new ToDoAdapter(data);
            recyclerView = findViewById(R.id.recyclerview);
            recyclerView.setHasFixedSize(true);
            recyclerView.setLayoutManager(layoutManager);
            recyclerView.setAdapter(adapters);
        }
    }

    public ToDoList(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

    }
}
